<?php

namespace app\api\controller\xiluhouse;

use app\common\controller\Api;
use app\api\logic\xiluhouse\PublishRentalLogic;

/**
 * @title   发布房源
 * @desc    独立的发布房源接口
 */
class PublishRental extends Api
{
    protected $noNeedRight = ['getParams'];
    protected $noNeedLogin = ['*'];

    /**
     * 发布房源
     */
    public function add()
    {
        $user = $this->auth->getUserinfo();
        $params = $this->request->post();

        $logic = new PublishRentalLogic();
        $result = $logic->addRental($params, $user);
        if ($result['code'] !== 1) {
            $this->error($result['msg']);
        }
        $this->success('发布成功', $result['data']);
    }

    /**
     * 获取参数
     */
    public function getParams()
    {
        $logic = new PublishRentalLogic();
        $result = $logic->getParams();
        $this->success('获取成功', $result);
    }

    /**
     * 上下架
     */
    public function multi_status(){
        $user = $this->auth->getUserinfo();
        $params = $this->request->post();

        $logic = new PublishRentalLogic();

        $result = $logic->multi_status($params, $user);
        if ($result['code'] !== 1) {
            $this->error($result['msg']);
        }
        $this->success('操作成功', $result['data']);
    }
} 